package main

import (
	"fmt"
	"sync"
)

var once sync.Once

func initConfig() {
	fmt.Println("Initializing config...")
}

func dojab(wg *sync.WaitGroup) {
	defer wg.Done()
	once.Do(initConfig) // 只会执行一次
}

func main() {
	var wg sync.WaitGroup
	for i := 0; i < 5; i++ {
		wg.Add(1)
		go dojab(&wg)
	}
	wg.Wait()
}
